ALTER VIEW [dbo].[View_FW_UserFunctionSet]
AS
SELECT fu.UserFunctionSetGUID,
       fu.UserGUID,
       fu.FunctionGUID,
       fu.IsSiteInner,
       fu.IsBroswerOpen,
       fu.UserFunctionSetIsSystem,
       fu.UserFunctionSetSort,
       fu.TenantId,
       fu.IsDeleted,
       fu.CreateTime,
       fu.BuUnitGUID,
	   fu.FunctionSetPinYin,
	   fu.FunctionSetFirstLeShort,

       (CASE fu.IsSiteInner
            WHEN 1 THEN
                ff.FunctionUrl
            ELSE
                fu.UserFunctionSetUrl
        END
       ) AS UserFunctionSetUrl,
       (CASE fu.IsSiteInner
            WHEN 1 THEN
       (CASE
            WHEN ISNULL(ff.Icon, '') = '' THEN
                'fa fa-file-text-o'
            ELSE
                ff.Icon
        END
       )
            ELSE
                fu.UserFunctionSetSiteIcon
        END
       ) AS UserFunctionSetSiteIcon,
	    (CASE fu.IsSiteInner
            WHEN 1 THEN
              ( CASE WHEN ISNULL(fu.UserFunctionSetName,'')='' THEN  ff.FunctionName ELSE fu.UserFunctionSetName END)
            ELSE
                fu.UserFunctionSetName
        END
       )  AS UserFunctionSetName
FROM dbo.FW_UserFunctionSet fu
    LEFT JOIN dbo.FW_Function ff
        ON fu.FunctionGUID = ff.FunctionGUID;